package com.db.transport;

import com.db.transport.client.SessionClient;
import com.db.transport.exchange.SessionExchange;
import com.db.transport.report.SessionReport;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

/**
 * @author nulls.narik
 */
public class SessionFactory {

    public static SessionClient getSessionClient(String clientID, InetAddress addressServer, int portServer) throws IOException {
        return new SessionClient(clientID, new Socket(addressServer, portServer));
    }

    public static SessionClient getSessionClient(String clientID, Socket socket, BufferedReader reader, PrintWriter writer) {
        return new SessionClient(clientID, socket, reader, writer);
    }

    public static SessionExchange getSessionExchange(String exchangeID, InetAddress addressServer, int portServer) throws IOException {
        return new SessionExchange(exchangeID, new Socket(addressServer, portServer));
    }

    public static SessionExchange getSessionExchange(String exchangeID, Socket socket, BufferedReader reader, PrintWriter writer) {
        return new SessionExchange(exchangeID, socket, reader, writer);
    }

    public static SessionReport getSessionReport(int portForClient, int portForExchange) throws IOException {
        return new SessionReport(portForClient, portForExchange);
    }

}
